#!/bin/bash
# Copyright (c) 2022 Huawei Technologies Co., Ltd
#
# This software is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

import sys
defaultencoding = 'utf-8'
if sys.getdefaultencoding() != defaultencoding:
    reload(sys)
    sys.setdefaultencoding(defaultencoding)

# -- Project information -----------------------------------------------------

project = u'Cangjie'
copyright = u'Cangjie 2022'

# -- General configuration ---------------------------------------------------

extensions = [
'recommonmark',
'sphinx_markdown_tables',
'sphinx_math_dollar',
'sphinx_copybutton',
'rst2pdf.pdfbuilder',
#'myst_parser',
'sphinx.ext.mathjax'
]

mathjax_path = "MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"

templates_path = ['_templates']

source_suffix = ['.rst', '.md']

master_doc = 'index'

project = u'Cangjie'
copyright = u'Cangjie 2022'
language = u'zh_CN'

today = ''

exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

suppress_warnings = ['myst.reference']

pygments_style = 'sphinx'

# -- Options for HTML output -------------------------------------------------
html_theme = "sphinx_book_theme"

html_codeblock_linenos_style = 'table'
#nbsphinx_requirejs_path = 'js/require.min.js'


html_static_path = ['_static']

html_last_updated_fmt = today

html_copy_source = False

html_show_sourcelink = False

def setup(app):
    app.add_css_file("css/mysphinx-theme.css")
    app.add_css_file("pygments.css")
    app.add_css_file("codemirror/lib/codemirror.css")
    app.add_js_file("js/header-test.js")
    app.add_js_file("codemirror/lib/codemirror.js")
    app.add_js_file("codemirror/mode/cangjie/cangjie.js")

# -- Options for HTMLHelp output ---------------------------------------------

htmlhelp_basename = 'sphinxdoc'

source_encoding = 'utf-8'

source_parsers = {
    '.md': 'recommonmark.parser.CommonMarkParser'
}

# -- Options for LaTeX output ------------------------------------------------

latex_engine = 'xelatex'
latex_elements = {
    'papersize': 'a4paper',
    'pointsize': '10pt',
    'geometry': r' \usepackage[left=2.5cm,right=2.5cm,top=2.54cm,bottom=2.54cm]{geometry}',
    'pxunit': '1bp',
    'preamble': r'''
        \usepackage{enumitem}
        \usepackage[document]{ragged2e}
        \usepackage[UTF8]{ctex}
        \usepackage{unicode-math}
        \usepackage[titles]{tocloft}
        \usepackage{amsmath}
        \usepackage{pdfpages}
        \usepackage{graphicx}
        \setcounter{tocdepth}{2}
        \setcounter{secnumdepth}{4}
        \usepackage{tabularx,multirow,bigdelim}
        \newcommand{\sectionbreak}{\clearpage}
        \newcommand{\lt}{\symbol{"3C}}% Less than
        \newcommand{\gt}{\symbol{"3E}}% Greater than
        \usepackage{ctex, draftwatermark, everypage}
        \SetWatermarkText{版权所有，禁止扩散}
        \SetWatermarkLightness{0.90}
        \SetWatermarkScale{0.45}
        \setCJKmainfont{Microsoft YaHei}
        \setCJKmonofont{Microsoft YaHei}
    ''',
    'figure_align': 'htbp',
    'maxlistdepth': '10',
    'printindex': '\\def\\twocolumn[#1]{#1}\\printindex',
    'extraclassoptions': 'openany,oneside',
    'sphinxsetup':\
    'verbatimforcewraps=true, \
    verbatimmaxoverfull=0, \
    inlineliteralwraps=false'
}

latex_toplevel_sectioning = None
latex_domain_indices = True
latex_show_pagerefs = False

#latex_logo = '_static/logo.png'

html_search_language = 'zh'


latex_use_xindy = False

latex_documents = [
    (master_doc, 'sphinx.tex', u'仓颉编程语言用户手册',
     u'华为技术有限公司', 'manual'),
]
#latex_theme = 'manual'
#latex_theme_options =


